<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Explain lifecycle API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'ilm-explain-lifecycle.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ilm-explain-lifecycle.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ilm-explain-lifecycle.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/ilm-explain-lifecycle.html" rel="nofollow" target="_blank">../en/ilm-explain-lifecycle.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="index-lifecycle-management-api.html">Index lifecycle management API</a></span>
»
<span class="breadcrumb-node">Explain lifecycle API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="ilm-get-status.html">« Get index lifecycle management status API</a>
</span>
<span class="next">
<a href="ilm-start.html">Start index lifecycle management API »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="ilm-explain-lifecycle"></a>Explain lifecycle API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/apis/explain.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<p>Shows an index’s current lifecycle status.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ilm-explain-lifecycle-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/apis/explain.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">GET &lt;index&gt;/_ilm/explain</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ilm-explain-lifecycle-prereqs"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/apis/explain.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
If the Elasticsearch security features are enabled, you must have the
<code class="literal">view_index_metadata</code> or <code class="literal">manage_ilm</code> or both privileges on the indices being
managed to use this API. For more information, see <a class="xref" href="security-privileges.html" title="Security privileges">Security privileges</a>.
</li>
</ul>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ilm-explain-lifecycle-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/apis/explain.asciidoc">edit</a>
</h3>
</div></div></div>
<p>Retrieves information about the index’s current lifecycle state, such as
the currently executing phase, action, and step. Shows when the index entered
each one, the definition of the running phase, and information
about any failures.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ilm-explain-lifecycle-path-params"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/apis/explain.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;index&gt;</code>
</span>
</dt>
<dd>
(Required, string) Identifier for the index.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ilm-explain-lifecycle-query-params"></a>Query parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/apis/explain.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">only_managed</code>
</span>
</dt>
<dd>
(Optional, boolean) Filters the returned indices to only indices that are managed by
ILM.
</dd>
<dt>
<span class="term">
<code class="literal">only_errors</code>
</span>
</dt>
<dd>
(Optional, boolean) Filters the returned indices to only indices that are managed by
ILM and are in an error state, either due to an encountering an error while
executing the policy, or attempting to use a policy that does not exist.
</dd>
<dt>
<span class="term">
<code class="literal">master_timeout</code>
</span>
</dt>
<dd>
(Optional, <a class="xref" href="common-options.html#time-units" title="Time units">time units</a>) Specifies the period of time to wait for
a connection to the master node. If no response is received before the timeout
expires, the request fails and returns an error. Defaults to <code class="literal">30s</code>.
</dd>
<dt>
<span class="term">
<code class="literal">timeout</code>
</span>
</dt>
<dd>
(Optional, <a class="xref" href="common-options.html#time-units" title="Time units">time units</a>) Specifies the period of time to wait for
a response. If no response is received before the timeout expires, the request
fails and returns an error. Defaults to <code class="literal">30s</code>.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ilm-explain-lifecycle-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/apis/explain.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The following example retrieves the lifecycle state of <code class="literal">my_index</code>:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET my_index/_ilm/explain</pre>
</div>
<div class="console_widget" data-snippet="snippets/1767.console"></div>
<p>When management of the index is first taken over by ILM, <code class="literal">explain</code> shows
that the index is managed and in the <code class="literal">new</code> phase:</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "indices": {
    "my_index": {
      "index": "my_index",
      "managed": true, <a id="CO586-1"></a><i class="conum" data-value="1"></i>
      "policy": "my_policy", <a id="CO586-2"></a><i class="conum" data-value="2"></i>
      "lifecycle_date_millis": 1538475653281, <a id="CO586-3"></a><i class="conum" data-value="3"></i>
      "age": "15s", <a id="CO586-4"></a><i class="conum" data-value="4"></i>
      "phase": "new",
      "phase_time_millis": 1538475653317, <a id="CO586-5"></a><i class="conum" data-value="5"></i>
      "action": "complete",
      "action_time_millis": 1538475653317, <a id="CO586-6"></a><i class="conum" data-value="6"></i>
      "step": "complete",
      "step_time_millis": 1538475653317 <a id="CO586-7"></a><i class="conum" data-value="7"></i>
    }
  }
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO586-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Shows if the index is being managed by ILM. If the index is not managed by
ILM the other fields will not be shown</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO586-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>The name of the policy which ILM is using for this index</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO586-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>The timestamp used for the <code class="literal">min_age</code></p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO586-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>The age of the index (used for calculating when to enter the next phase)</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO586-5"><i class="conum" data-value="5"></i></a></p>
</td>
<td align="left" valign="top">
<p>When the index entered the current phase</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO586-6"><i class="conum" data-value="6"></i></a></p>
</td>
<td align="left" valign="top">
<p>When the index entered the current action</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO586-7"><i class="conum" data-value="7"></i></a></p>
</td>
<td align="left" valign="top">
<p>When the index entered the current step</p>
</td>
</tr>
</table>
</div>
<p>Once the policy is running on the index, the response includes a
<code class="literal">phase_execution</code> object that shows the definition of the current phase.
Changes to the underlying policy will not affect this index until the current
phase completes.</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "indices": {
    "test-000069": {
      "index": "test-000069",
      "managed": true,
      "policy": "my_lifecycle3",
      "lifecycle_date_millis": 1538475653281,
      "lifecycle_date": "2018-10-15T13:45:21.981Z",
      "age": "25.14s",
      "phase": "hot",
      "phase_time_millis": 1538475653317,
      "phase_time": "2018-10-15T13:45:22.577Z",
      "action": "rollover",
      "action_time_millis": 1538475653317,
      "action_time": "2018-10-15T13:45:22.577Z",
      "step": "attempt-rollover",
      "step_time_millis": 1538475653317,
      "step_time": "2018-10-15T13:45:22.577Z",
      "phase_execution": {
        "policy": "my_lifecycle3",
        "phase_definition": { <a id="CO587-1"></a><i class="conum" data-value="1"></i>
          "min_age": "0ms",
          "actions": {
            "rollover": {
              "max_age": "30s"
            }
          }
        },
        "version": 3, <a id="CO587-2"></a><i class="conum" data-value="2"></i>
        "modified_date": "2018-10-15T13:21:41.576Z", <a id="CO587-3"></a><i class="conum" data-value="3"></i>
        "modified_date_in_millis": 1539609701576 <a id="CO587-4"></a><i class="conum" data-value="4"></i>
      }
    }
  }
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO587-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>The JSON phase definition loaded from the specified policy when the index
entered this phase</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO587-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>The version of the policy that was loaded</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO587-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>The date the loaded policy was last modified</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO587-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>The epoch time when the loaded policy was last modified</p>
</td>
</tr>
</table>
</div>
<p>If ILM is waiting for a step to complete, the response includes status
information for the step that’s being performed on the index.</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "indices": {
    "test-000020": {
      "index": "test-000020",
      "managed": true,
      "policy": "my_lifecycle3",
      "lifecycle_date_millis": 1538475653281,
      "lifecycle_date": "2018-10-15T13:45:21.981Z",
      "age": "4.12m",
      "phase": "warm",
      "phase_time_millis": 1538475653317,
      "phase_time": "2018-10-15T13:45:22.577Z",
      "action": "allocate",
      "action_time_millis": 1538475653317,
      "action_time": "2018-10-15T13:45:22.577Z",
      "step": "check-allocation",
      "step_time_millis": 1538475653317,
      "step_time": "2018-10-15T13:45:22.577Z",
      "step_info": { <a id="CO588-1"></a><i class="conum" data-value="1"></i>
        "message": "Waiting for all shard copies to be active",
        "shards_left_to_allocate": -1,
        "all_shards_active": false,
        "actual_replicas": 2
      },
      "phase_execution": {
        "policy": "my_lifecycle3",
        "phase_definition": {
          "min_age": "0ms",
          "actions": {
            "allocate": {
              "number_of_replicas": 2,
              "include": {
                "box_type": "warm"
              },
              "exclude": {},
              "require": {}
            },
            "forcemerge": {
              "max_num_segments": 1
            }
          }
        },
        "version": 2,
        "modified_date": "2018-10-15T13:20:02.489Z",
        "modified_date_in_millis": 1539609602489
      }
    }
  }
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO588-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Status of the step that’s in progress.</p>
</td>
</tr>
</table>
</div>
<p>If the index is in the ERROR step, something went wrong while executing a
step in the policy and you will need to take action for the index to proceed
to the next step. Some steps are safe to automatically be retried in certain
circumstances. To help you diagnose the problem, the explain response shows
the step that failed, the step info which provides information about the error,
and information about the retry attempts executed for the failed step if it’s
the case.</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "indices": {
    "test-000056": {
      "index": "test-000056",
      "managed": true,
      "policy": "my_lifecycle3",
      "lifecycle_date_millis": 1538475653281,
      "lifecycle_date": "2018-10-15T13:45:21.981Z",
      "age": "50.1d",
      "phase": "hot",
      "phase_time_millis": 1538475653317,
      "phase_time": "2018-10-15T13:45:22.577Z",
      "action": "rollover",
      "action_time_millis": 1538475653317,
      "action_time": "2018-10-15T13:45:22.577Z",
      "step": "ERROR",
      "step_time_millis": 1538475653317,
      "step_time": "2018-10-15T13:45:22.577Z",
      "failed_step": "check-rollover-ready", <a id="CO589-1"></a><i class="conum" data-value="1"></i>
      "is_auto_retryable_error": true, <a id="CO589-2"></a><i class="conum" data-value="2"></i>
      "failed_step_retry_count": 1, <a id="CO589-3"></a><i class="conum" data-value="3"></i>
      "step_info": { <a id="CO589-4"></a><i class="conum" data-value="4"></i>
        "type": "cluster_block_exception",
        "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] blocked by: [FORBIDDEN/5/index read-only (api)",
        "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg",
        "index": "test-000057"
      },
      "phase_execution": {
        "policy": "my_lifecycle3",
        "phase_definition": {
          "min_age": "0ms",
          "actions": {
            "rollover": {
              "max_age": "30s"
            }
          }
        },
        "version": 3,
        "modified_date": "2018-10-15T13:21:41.576Z",
        "modified_date_in_millis": 1539609701576
      }
    }
  }
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO589-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>The step that caused the error</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO589-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>Indicates if retrying the failed step can overcome the error. If this
is true, ILM will retry the failed step automatically.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO589-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>Shows the number of attempted automatic retries to execute the failed
step.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO589-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>What went wrong</p>
</td>
</tr>
</table>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="ilm-get-status.html">« Get index lifecycle management status API</a>
</span>
<span class="next">
<a href="ilm-start.html">Start index lifecycle management API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>